#include "Ellipse.h"

Ellipse::Ellipse() : Region() //Boringly enough, just a circle
{
	major = 1.0;
	minor = 1.0;
}

Ellipse::Ellipse(double majorRad, double minorRad) : Region()
{
	major = majorRad;
	minor = minorRad;
}

double Ellipse::getMajorRad()
{
	return major;
}

double Ellipse::getMinorRad()
{
	return minor;
}

double Ellipse::getEccentricity()
{
	return (major >= minor)? sqrt(1.0-(minor*minor)/(major*major)): sqrt(1.0-(major*major)/(minor*minor));
}

double Ellipse::getCircumference() //A good, but NOT exact, approximation
{
	double h = ((major-minor)*(major-minor))/((major+minor)*(major+minor));
	return M_PI*(major+minor)*(1.0+((3.0*h)/(10.0+sqrt(4.0-3.0*h))));
}

bool Ellipse::pointInside(double *position, double error)
{
	if((position[0]*position[0])/(major*major) + (position[1]*position[1])/(minor*minor) < 1.0)//The point is within the ellipse
	{
		return true;
	}
	else
	{
		return false;
	}
}